Skip to content

[RF] Zero out negative bins in RooHistPdf for consistent normalization - #23103

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:histpdf-clamp-negative-bins
Aug 21, 2026
Merged

[RF] Zero out negative bins in RooHistPdf for consistent normalization#23103
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:histpdf-clamp-negative-bins

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

A RooHistPdf clamps negative bin contents to zero when evaluating, but its normalization integral was based on the plain sum of the bin weights, including the negative ones. A histogram with negative bins therefore yielded a pdf that did not integrate to unity, silently biasing in particular the yields of extended fits: even an Asimov fit with a model identical to the generating pdf did not close.

Now, if the input histogram contains bins with negative content, these are set to zero in an internally-owned clone of the histogram that is used instead, with a warning. This makes the pdf value and its normalization consistent, restoring exact closure. The input histogram is not modified, and bin errors are preserved.

The RooHistPdf constructed by RooAbsCachedPdf implementations like RooFFTConvPdf is unaffected, because the cache histogram is still empty at construction time and only filled (in place) afterwards.

Fixes ROOT-10825.

🤖 Done with the help of AI

Comment thread roofit/roofitcore/src/RooHistPdf.cxx Outdated
@guitargeek
guitargeek force-pushed the histpdf-clamp-negative-bins branch from d2d9854 to 773da6b Compare August 19, 2026 11:57
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 12h 32m 58s ⏱️
 3 856 tests  3 855 ✅ 0 💤 1 ❌
75 984 runs  75 982 ✅ 1 💤 1 ❌

For more details on these failures, see this check.

Results for commit 3442985.

♻️ This comment has been updated with latest results.

Comment thread roofit/roofitcore/src/RooHistPdf.cxx Outdated
Comment thread roofit/roofitcore/src/RooHistPdf.cxx Outdated

@hageboeck hageboeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the implementation details that leaked into the comments, LGTM

@dpiparo dpiparo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once Stephan's comments are addressed.

@guitargeek
guitargeek force-pushed the histpdf-clamp-negative-bins branch from 773da6b to 0546b53 Compare August 21, 2026 13:49
@guitargeek

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews! PR is updated with improved docs and error messages that don't talk about implementation details ("internal histogram clones") anymore.

A RooHistPdf clamps negative bin contents to zero when evaluating, but
its normalization integral was based on the plain sum of the bin
weights, including the negative ones. A histogram with negative bins
therefore yielded a pdf that did not integrate to unity, silently
biasing in particular the yields of extended fits: even an Asimov fit
with a model identical to the generating pdf did not close.

Now, if the input histogram contains bins with negative content, these
are set to zero in an internally-owned clone of the histogram that is
used instead, with a warning. This makes the pdf value and its
normalization consistent, restoring exact closure. The input histogram
is not modified, and bin errors are preserved.

The RooHistPdf constructed by RooAbsCachedPdf implementations like
RooFFTConvPdf is unaffected, because the cache histogram is still empty
at construction time and only filled (in place) afterwards.

Fixes ROOT-10825.

🤖 Done with the help of AI
@guitargeek
guitargeek force-pushed the histpdf-clamp-negative-bins branch from 0546b53 to 3442985 Compare August 21, 2026 15:28
@guitargeek
guitargeek merged commit a26952a into root-project:master Aug 21, 2026
31 of 34 checks passed
@guitargeek
guitargeek deleted the histpdf-clamp-negative-bins branch August 21, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants